package com.eatme.web.security.authentication.domain.entity;

import com.eatme.web.security.authentication.constant.IdentityType;
import com.eatme.web.security.authentication.converter.IdentityTypeConverter;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;

@Entity
@Table(name="sys_user_auth")
public class SecurityUserAuth {

    @Id
    @Column(name="id",nullable = false)
    private Integer id;

    @Column(name="user_id",nullable = false)
    private Integer userId;

    @Column(name="credential",nullable = false)
    private String credential;

    @Column(name="identifier",nullable = false)
    private String identifier;
    @Column(name="identity_type",nullable = false)
    @Convert(converter= IdentityTypeConverter.class)
    private IdentityType identityType;

    @ManyToOne(targetEntity = SecurityUser.class,fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id",referencedColumnName = "id", insertable = false, updatable = false)
    @JsonIgnore
    private SecurityUser securityUser;

    public SecurityUserAuth() {

    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getCredential() {
        return credential;
    }

    public void setCredential(String credential) {
        this.credential = credential;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public IdentityType getIdentityType() {
        return identityType;
    }

    public void setIdentityType(IdentityType identityType) {
        this.identityType = identityType;
    }

    public SecurityUser getSecurityUser() {
        return securityUser;
    }

    public void setSecurityUser(SecurityUser securityUser) {
        this.securityUser = securityUser;
    }
}
